<template>
	<view class="container bg-white">
		<view class="bg-grey">
			<view class="padv20">
				<u-grid col="4">
					<u-grid-item v-for="(item, index) in typeList" :key="item.id"
						@click="$go2( $makeUrl( item.page,{pid:item.id}))">
						<sb-img w="120" shadow mode='center' :src="$getStaticUrl(item.cover)" />
						<u-gap height="10"></u-gap>
						<view>{{item.name}}</view>
					</u-grid-item>
				</u-grid>
			</view>
			<view class="flex j-s padh20">
				<view v-for="(sku, index) in picList" :key="index" class="marv15 radius10 bg-white">
					<navigator :url="`/pages/pic/detail?id=${sku.id}`">
						<sb-img w='340' h='400' shadow :src="$getStaticUrl(sku.path)" />
					</navigator>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import { RECOMMEND_TYPE } from "@/config/enum.js";
	import { mapGetters, mapState } from "vuex";
	export default {
		data() {
			return {
				banners: [],
				typeList: [],
				picList: [],
				qs: {
					page: 1,
					size: 20
				}
			};
		},
		onShareAppMessage() {

		},
		onShareTimeline() {

		},
		onPullDownRefresh() {
			setTimeout(() => uni.stopPullDownRefresh(), 500)
			this.qs.page = 1
			this.picList = []
			this.$nextTick(() => this.getList())
		},
		onLoad() {
			this.getTypeList()
			this.getList();
		},
		onReachBottom() {
			this.qs.page++
			this.getList()
		},
		methods: {
			async getList() {
				let { success, data } = await this.$get("/pic", this.qs, false);
				if (success) {
					this.picList = this.picList.concat(data.rows)
				}
			},
			async getTypeList() {
				let { success, data } = await this.$get("/type", { pid: 0 }, false);
				if (success) {
					this.typeList = data
				}
			},
		},
	};
</script>

<style lang="scss" scoped>
	.container {
		/deep/ {
			.u-tabbar__content {
				position: absolute;
			}

			.u-sticky {
				background-color: #fff;
			}
		}
	}
</style>
